悬赏已过期 后悬赏过期
悬赏

中望cad执行lsp调用 ActiveX 对象的方法的时候无效

邀请:
(defun c:p2 (/		 ConfigName  PaperName	 PaperWidth
	     PaperHeight OutputFilePath		 oldvar
	     ActDoc	 Plot	     Layout	 ss
	     num	 ent	     ent_pt	 Counter
	     pt1	 pt2	     point1	 pointTemp1
	     point2	 pointTemp2  scalex	 scaley
	     scale	 outputFileName
	    )
  
;;=======================================================================
  (setq ConfigName "DWG to PDF_ZW.pc5")
  (setq PaperName "ISO_full_bleed_A3_(297.00_x_420.00_MM)")
  (setq PaperWidth 297)
  (setq PaperHeight 420)
  (setq OutputFilePath "C:\\Users\\x5051\\Desktop\\1")
;;=======================================================================

  
  (setq oldvar (getvar "backgroundplot"))
  (setvar "backgroundplot" 0)
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-zwcad-object)))  ;;;;;;;;无法获取到中望CAD的文件对象
  (setq ActDoc (vla-get-name AcadObj))
  (setq Plot (vla-get-plot ActDoc))  
  (setq Layout (vla-get-activelayout ActDoc))  
  
  (setq ss (ssget '((0 . "TEXT") (8 . "排序"))))
  (setq num (sslength ss))

  (while (> num 0)
    (setq ent (ssname ss (setq num (1- num))))
    (setq ent_pt (entget ent (list "APPID_CYS_LB_PT" "APPID_CYS_RT_PT")))
    (setq Counter (cdr(assoc 1 ent_pt)))
    (setq pt1 (cdr (cadr (cadr (assoc -3 ent_pt)))))
    (setq pt2 (cdr (cadr (caddr (assoc -3 ent_pt)))))

    (setq point1 (vlax-variant-value (vlax-3d-point pt1)))
    (setq pointTemp1 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-put-element pointTemp1 0 (vlax-safearray-get-element point1 0))
    (vlax-safearray-put-element pointTemp1 1 (vlax-safearray-get-element point1 1))
    
    (setq point2 (vlax-variant-value (vlax-3d-point pt2)))
    (setq pointTemp2 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-put-element pointTemp2 0 (vlax-safearray-get-element point2 0))
    (vlax-safearray-put-element pointTemp2 1 (vlax-safearray-get-element point2 1))
    
    ; 设置打印相关参数
    (vla-put-paperunits Layout zcMillimeters)  ; 设置单位为mm
    (vla-put-plotrotation Layout zc0degrees)  ; 设置打印方向为0度
    (vla-put-centerplot Layout :vlax-true)  ; 自动居中
    (setq scalex (fix(+ 0.5(/ (abs (- (car pt1) (car pt2))) PaperWidth))))
    (setq scaley (fix(+ 0.5(/ (abs (- (cadr pt1) (cadr pt2))) PaperHeight))))
    (setq scale (max scalex scaley))
    (vla-setcustomscale Layout 1 scale)  ; 设置比例
    
    (vla-put-CanonicalMediaName Layout PaperName)  ; 设置纸张大小
    (vla-put-ConfigName Layout ConfigName)
    (vla-SetWindowToPlot Layout pointTemp1 pointTemp2)
    (vla-put-plottype Layout acWindow)

    (vla-put-NumberofCopies Plot 1)
    
    (setq outputFileName (strcat OutputFilePath "\\output" Counter ".pdf"))
    (vla-plotTofile Plot outputFileName)
    
  )

  (setvar "backgroundplot" oldvar)
  )

(vlax-get-zwcad-object)无法获取到中望cad对象,(vla-put-paperunits Layout zcMillimeters)(vla-put-plotrotation Layout zc0degrees)(vla-put-centerplot Layout :vlax-true),打印参数好像也无法设置,有没有大佬帮忙看一下问题!!!

收藏1
分享
您的回答

回答

默认排序 时间排序
图片审查中...
购物车
优惠劵
今日签到
有新私信 私信列表
搜索
复制链接
微信扫码
已复制到剪贴板