Jump to content

Best Method? Move objects in Model space and re-align multiple viewports?


Recommended Posts

I have a a drawing in Model Space and have multiple tabs with multiple viewports all displaying different views,

objects and scales of the geometry in Model Space.

I now need to move all the geometry in Model Space.

I know about ALIGNSPACE where you can adjust the alignment one viewport at a time..

With multiple viewports affected by the model space move, is there a "quick" way to realign all the viewports

with their respective geometry? Maybe all at once??

The move will affect them all "relative" one to another.

All my searching only returns how to move FROM Model Space TO Paper Space and back

 

Please advise

Link to comment
Share on other sites

It depends on how many viewports you have and how they're oriented, but you may be able to save a view for one viewport and set others to that same view.

 

Here's an official explanation: To Save and Name a View

 

It's always easier to create the view first and the viewports later, because it's easier to lay out plans when you can predict the future.

Link to comment
Share on other sites

Is the answer in having dummy rectangs in Model ? Then just read these and make viewports to match in layouts. I do this for follow a pline in road design.

Link to comment
Share on other sites

I'm going to use the BIGAL method.

I was hoping there was an easier way..

I have tabs with 1 view and tabs with 7 views and everything in between...

ALIGNSPACE is my buddy...

 

I can't be the first person who has needed to move Model Space geometry and needed the Paper Space viewports to track with the geometry move...

 

<sigh..>

 

thanks..

  • Like 1
Link to comment
Share on other sites

I work mainly CIVIL so we never moved the model we did though use UCS and would save multiple UCS's then in viewport its a "UCS R name"  this would have the twist etc then set the scale. 

 

If you unlock a viewport and use UCS OB can set the twist very quick. Just be careful to not pick a 3d object.

Link to comment
Share on other sites

might provide a little help @ILoveMadoka

 

;;----------------------------------------------------------------------------;;
;; Creates Viewport outline and moves it to Model space
(defun C:VP2M (/ SS vp elist MiscOn cen c40 c41 LL UR)
  (if (setq SS (ssget "_X" (list '(0 . "viewport") (cons 410 (getvar 'ctab)))))
    (foreach vp (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))
      (setq elist (entget vp))
      (if (> (cdr (assoc '69 elist)) 1)              ; skip display viewport
        (progn
          (if (= (cdr (assoc '68 elist)) 0)          ; is viewport active?
            (progn
              (setq MiscOn 'NO)
              (vl-cmdf "._Mview" "_on" "_si" vp)  ; activate viewport
            )  ; progn
            (setq MiscOn 'YES)
          )    ; if
          (setq cen (cdr (assoc '10 elist))
                c40 (cdr (assoc '40 elist)) ;length
                c41 (cdr (assoc '41 elist)) ;width
                LL (list (- (car cen) (/ c40 2)) (- (cadr cen) (/ c41 2)))
                UR (list (+ (car cen) (/ c40 2)) (+ (cadr cen) (/ c41 2)))
          )
          (vl-cmdf "_.Pspace")
          (vl-cmdf "_.Rectangle" LL UR)
          (vl-cmdf "_.Chspace" "_Last" "")
          (vl-cmdf "_.Pspace")
          (if (eq MiscOn 'NO)
            (vl-cmdf "_.Mview" "_off" "_si" vp)  ; deactivate viewport
          )
        )
      )
    )
  )
  ;(setvar 'Tilemode 1) ;go to model space
  (princ)

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I don't remember where I got this lisp but still is working until now .

Credits to the owner / author of the lisp file

 

(defun c:hvpo_help ()
	(prompt "\n\nhvpo Module")
	(prompt "\n  c:hvpo_getXData")
	(prompt "\n      Returns the model space viewport data it has")
	(prompt "\n      associated to it.")
	(prompt "\n  c:hvpo_help")
	(prompt "\n      Displays this help information.")
	(prompt "\n  c:hvpo_ss")
	(prompt "\n      Routine that sets the scale of the drawing")
	(prompt "\n      by selecting a model space view port.")
	(prompt "\n      Will not run without helpers.")
	(prompt "\n  c:hvpo_sync")
	(prompt "\n      Main routine to syncronize viewports in a ")
	(prompt "\n      drawing with a model space viewport object.")
	(prompt "\n  (hvpo:viewPortToggle)")
	(prompt "\n      Routine to toggle the viewport layer when in")
	(prompt "\n      paper space. Will not run without helpers.")
	(prompt "\n")
	(princ)
)

(defun hvpo:viewPortToggle ( / &vVpLayer &vCurLayer)
	(if (setq &vVpLayerTest (tblobjname "layer" "1_Vport"))
		(progn
			(setq &vVpLayer (entget &vVpLayerTest))
			(if (= (cdr (assoc 70 &vVpLayer)) 0)
				(progn
					(setq &vCurLayer (getvar "clayer"))
					(if (= &vCurLayer "1_Vport")
						(command "-layer" "set" "0" "")
					)
					(hlay:setLayerProperty "1_Vport" "Freeze" "True")
					(prompt "\n Viewport Off")
				)
				(progn
					(hlay:setLayerProperty "1_Vport" "Freeze" "False")
					(vlax-invoke-method (vla-get-activedocument (vlax-get-acad-object)) "Regen" acAllViewports
)
					(prompt "\n Viewport On")
				)
			)
		)
		(progn
			(prompt "\n No viewport Layer")
		)
	)
	(princ)
)

(defun c:hvpo_sync ( / &vActLayout &vAcadDoc &vLayoutColl &vLayoutList &vCnt &vLayoutObj &vBlockColl &vCnt2
					 &vBlockObj &vXdType &vXdData &vVpCheck &vCurlayer)
	(vl-load-com)
	;;	get all the layouts in the drawing
	(prompt "\n\nBeginning viewport sync...")
	(setq &vCurLayer (getvar "clayer"))
	;;(hlay:setLayer "0")

	;;(hlay:setLayerProperty "1_Vport" "On" "True")
	;;(hlay:setLayerProperty "1_Vport" "Lock" "False")
	;;(hlay:setLayerProperty "1_Vport" "Freeze" "False")
	(command "-layer" "s" "0" "")
	(if(= (tblsearch "layer" "1_Vport_MS") nil)
  	    (progn
  	    	(command "-layer" "m" "1_Vport_MS" "c" 1 "" "p" "n" "" "lt" "continuous" "" "")
  	    )
  	    (progn
  			(command "-layer" "s" "1_Vport_MS" "c" 1 "" "p" "n" "" "lt" "continuous" "" "on" "1_Vport_MS" "Thaw" "1_Vport_MS" "unlock" "1_Vport_MS" "")
  		)
  	)

	(setq &vActLayout (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))

	(setq &vAcadDoc (vla-get-activedocument (vlax-get-acad-object)))
	(setq &vLayoutColl (vla-get-layouts &vAcadDoc))

	(setq &vLayoutList nil)

	(setq &vCnt 0)
	(while (<= &vCnt (- (vlax-get-property &vLayoutColl "count") 1))
		(setq &vLayoutObj (vlax-invoke-method &vLayoutColl "item" &vCnt))
		(prompt (strcat "\n  Setting Layout..." (vlax-get-property &vLayoutObj "Name")))
		(vla-put-activelayout &vAcadDoc &vLayoutObj)

		(if (not (= (vlax-get-property &vLayoutObj "name") "Model"))
			;;	for each viewport in each layout add or update viewports in the modelspace.
			(progn
				(setq &vBlockColl (vla-get-block &vLayoutObj))
				(prompt "\n   getting viewport... ")
				(setq &vCnt2 0)
				(while (<= &vCnt2 (- (vlax-get-property &vBlockColl "Count") 1))
					(setq &vBlockObj (vlax-invoke-method &vBlockColl "item" &vCnt2))
					(if (= (vlax-get-property &vBlockObj "objectname") "AcDbViewport")
						(progn
							(prompt (strcat " " (vlax-get-property &vBlockObj "handle")))
							(vlax-invoke-method &vBlockObj "GetXData" "" '&vXdType '&vXdData)
							(setq &vVpCheck (vlax-variant-value (vlax-safearray-get-element &vXdData 16)))
							(if (and (not (= &vVpCheck 0))(not (= &vVpCheck 1)))
								(progn
									(setq &vLayoutList (append &vLayoutList (list (vlax-get-property &vBlockObj "handle"))))
									(hvpo:vp (vlax-vla-object->ename &vBlockObj))
								)
							)
						)
					)
					(setq &vCnt2 (+ &vCnt2 1))
				)
			)
		)
		(setq &vCnt (+ &vCnt 1))
	)
	(vla-put-activelayout (vla-get-activedocument (vlax-get-acad-object)) &vActLayout)
	(prompt "\n               back to the acitve layout")
	;;(hlay:setLayer &vCurLayer)
	(command "-layer" "s" &vCurLayer "")

	(prompt "Complete.")

	;;	release vl objects
	(if &vActLayout (vlax-release-object &vActLayout))
	(if &vAcadDoc (vlax-release-object &vAcadDoc))
	(if &vLayoutColl (vlax-release-object &vLayoutColl))
	(if &vLayoutObj (vlax-release-object &vLayoutObj))
	(if &vBlockColl (vlax-release-object &vBlockColl))
	(if &vBlockObj (vlax-release-object &vBlockObj))

	(gc)

	(princ)
)

;(defun hvpo:cleanup_old_msviewports (layoutList /)
;	(setq &vSS1 (ssget "_X" '((-3 ("ViewPortAssociation")))))
;	(setq &vCnt 0)
;	(while (<= &vCnt (- (length layoutList) 1))
;		(setq vpHandle "")
;
;	)
;)

(defun hvpo:vp (&gEnt / &vEntHandle &vMsVpObj)
    ;;(setq &vEnt (car (entsel)))
    (prompt "\n    Checking for add or Update")
    (setq &vEntHandle (cdr (assoc 5 (entget &gEnt))))

    ;;  search for a block in the drawing with the selected viewports
    ;;  handle associated to the 1001 xdata.
    (setq &vMsVpObj (hvpo:getViewPortAssociation_MSObject (cdr (assoc 5 (entget &gEnt)))))
    (if &vMsVpObj
        (hvpo:updateViewPortAssociation_MSObject &gEnt &vMsVpObj)
        (hvpo:addViewPortAssociation_MSObject &gEnt)
    )
)

;;	with a viewport handle, perform a select on all objects in the database
;;	that have extended data "ViewPortAssociation" application name associated
;;	to them. If an one is found then return that object. If no objects are found
;;	then return nil.
;;	If more than one is found that means there is a problem. someone has duplicated
;;	the viewport entity and if this happens syncronization operations will not work
;;	as expected. Remove all entities, delete the block reference from the drawing and
;;	return nil. This will allow the resync portion of the program to create a new
;;	viewport block for the viewport.
(defun hvpo:getViewPortAssociation_MSObject (&gEntHandle / &vObjFnd &vSS1 &vCnt &vEnt &vVlaent &vXdType &vXdData
													&vTmpHandle &vReturn)
    (prompt " ...    Finding viewport MS object...")
    (setq &vReturn nil)
    (setq &vObjFnd 0)
    (setq &vSS1 (ssget "_X" '((0 . "INSERT")(-3 ("ViewPortAssociation")))))

    (if &vSS1
        (progn
            (setq &vCnt 0)

            (prompt (strcat "\n   Stepping into the selection set looking for " (vl-princ-to-string &gEntHandle)))

            (while (<= &vCnt (- (sslength &vSS1) 1))
                (setq &vEnt (ssname &vSS1 &vCnt))
                (setq &vVlaent (vlax-ename->vla-object &vEnt))
                (vlax-invoke-method &vVlaent "GetXData" "ViewPortAssociation" '&vXdType '&vXdData)
                (setq &vTmpHandle (vlax-variant-value (nth 1 (vlax-safearray->list &vXdData))))
            	(prompt ".")
                (if (= &gEntHandle &vTmpHandle)
                    (progn
                        (setq &vObjFnd (+ &vObjFnd 1))
                        (setq &vReturn &vEnt)
                    )
                )
                (setq &vCnt (+ &vCnt 1))
            )
            (prompt (strcat "\n   Selection set count " (vl-princ-to-string (sslength &vSS1))))
    		(prompt (strcat "\n   Number of viewport objects found " (vl-princ-to-string &vObjFnd)))
        )
        (prompt "No entities found")
    )
    (if (>= &vObjFnd 2)
    	(progn
    		(prompt "\n    Error... more than one viewport entity found.")
    		(hvpo:deleteViewpPortAssociation_MSObject &gEntHandle)
    		(setq &vReturn nil)
    	)
    )
    ;;	release vl objects
	(if &vVlaent (vlax-release-object &vVlaent))

    &vReturn
)

(defun hvpo:deleteViewpPortAssociation_MSObject (&gEntHandle / &vSS1 &vCnt &vEnt &vVlaent &vXdType &vXdData &vTmpHandle &vBlockColl &vBlockObj &vBlockName)
	(prompt "\n    Cleaning outdated or multiple viewport MS objects...")
	(setq &vSS1 (ssget "_X" '((0 . "INSERT")(-3 ("ViewPortAssociation")))))
    (if &vSS1
        (progn
            (setq &vCnt 0)
            (while (<= &vCnt (- (sslength &vSS1) 1))
                (setq &vEnt (ssname &vSS1 &vCnt))
                (setq &vVlaent (vlax-ename->vla-object &vEnt))
                (vlax-invoke-method &vVlaent "GetXData" "ViewPortAssociation" '&vXdType '&vXdData)
                (setq &vTmpHandle (vlax-variant-value (nth 1 (vlax-safearray->list &vXdData))))
                (if (= &vEntHandle &vTmpHandle)(vlax-invoke-method &vVlaent "Delete"))
                (setq &vCnt (+ &vCnt 1))
            )
        )
    )
    (prompt "\n    Removing Block")
    (setq &vBlockColl (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
    (setq &vCnt 0)
    (while (<= &vCnt (- (vlax-get-property &vBlockColl "Count") 1))
        (setq &vBlockObj (vlax-invoke-method &vBlockColl "item" &vCnt))
        ;(prompt (strcat "\n      Block: " (vlax-get-property &vBlockObj "name")))

        (setq &vBlockName (strcat "ViewPortAssociation_MSObject_" &vEntHandle))
        (if (= (vlax-get-property &vBlockObj "Name") &vBlockName)
        	(progn
        		(vlax-invoke-method &vBlockObj "Delete")
        		(prompt "... removed")
        	)
        )
        (setq &vCnt (+ &vCnt 1))
    )
    ;;	release vl objects
	(if &vVlaent (vlax-release-object &vVlaent))
	(if &vBlockColl (vlax-release-object &vBlockColl))
	(if &vBlockObj (vlax-release-object &vBlockObj))

    (princ)
)

(defun hvpo:updateViewPortAssociation_MSObject (&gVpEnt &gMsBlockObj / &vVlaent &vXdType &vXdData &vBlockObj &vMsVpScale &vMsVpHeight &vMsVpWidth &vBlockObjIns &vVp &vPsVpHeight &vPsVpWidth &vScaleRatio &vVpScale &vAcadDoc)
    (prompt "\n    Updating Viewport Link...")
    (setq &vAcadDoc (vla-get-activedocument (vlax-get-acad-object)))

    ;;	check to see if the viewport size matches the block entity in ms
	(setq &vVlaent (vlax-ename->vla-object &gMsBlockObj))
	(vlax-invoke-method &vVlaent "GetXData" "ViewPortAssociation" '&vXdType '&vXdData)
    (setq &vBlockObj (vlax-ename->vla-object &gMsBlockObj))
	(if &vXdData
		(progn
			(setq &vMsVpScale (vlax-variant-value (vlax-safearray-get-element &vXdData 3)))
			(setq &vMsVpHeight (vlax-variant-value (vlax-safearray-get-element &vXdData 4)))
			(setq &vMsVpWidth (vlax-variant-value (vlax-safearray-get-element &vXdData 5)))
		)
	)

    (setq &vBlockObjIns (vlax-get-property &vBlockObj "InsertionPoint"))

    (setq &vVp (vlax-ename->vla-object &gVpEnt))
    (setq &vPsVpHeight (vlax-get-property &vVp "height"))
    (setq &vPsVpWidth (vlax-get-property &vVp "width"))
    (setq &vScaleRatio (vlax-get-property &vVp "CustomScale"))
	(setq &vVpScale (/ 1 (vlax-get-property &vVp "CustomScale")))

	(prompt (strcat "\n    Viewport Scale: " (rtos &vScaleRatio 2) " Width: " (rtos &vPsVpWidth 2) " Height: " (rtos &vPsVpHeight 2)))
	(prompt (strcat "\n    ModelSpa Scale: " (rtos &vMsVpScale 2) " Width: " (rtos &vMsVpWidth 2) " Height: " (rtos &vMsVpHeight 2)))

	(vlax-put-property &vAcadDoc "MSPACE" "False")
	(vlax-invoke-method (vlax-get-acad-object) "ZoomExtents")
    (if (and (= (* &vPsVpHeight &vVpScale) &vMsVpHeight)(= (* &vPsVpWidth &vVpScale) &vMsVpWidth))
    	(progn
    		;;	if the viewport height and width match then update the viewport view.
    		(vlax-put-property &vVp "DisplayLocked" :vlax-False)
    		(vlax-invoke-method &vVp "Display" :vlax-true)
    		(vlax-put-property &vVp "viewporton" :vlax-true)
    		(vlax-invoke-method &vVp "update")

    		(vlax-put-property &vAcadDoc "MSPACE" "True")
   			(vla-put-activepviewport &vAcadDoc &vVp)

    		(vlax-invoke-method (vlax-get-acad-object) "ZoomCenter" &vBlockObjIns 1)
    		(vlax-put-property &vVp "CustomScale" &vScaleRatio)
			(vlax-put-property &vAcadDoc "MSPACE" "False")
    		(vlax-put-property &vVp "DisplayLocked" :vlax-True)
    	)
		(progn
			;;	if the viewport height and width dont match then delete the ms viewport and recreate it.
    		(hvpo:deleteViewpPortAssociation_MSObject (vlax-get-property &vVp "handle"))
    		(hvpo:addViewPortAssociation_MSObject &gVpEnt)
    	)
    )
    ;;	release vl objects
	(if &vAcadDoc (vlax-release-object &vAcadDoc))
	(if &vVlaent (vlax-release-object &vVlaent))
	(if &vBlockObj (vlax-release-object &vBlockObj))
	(if &vVp (vlax-release-object &vVp))
    (princ)
)

(defun hvpo:addViewPortAssociation_MSObject (&gVpEnt / &vVlaent &vEntHandle &vXdType &vXdData &vCnX &vCnY &vVpScale &vWidth &vHeight &vBlockName &vSS1 &vEnt &vVlaent &vBlockColl &vCnt &vBlockObj &vNewBlock &vX1 &vX2 &vY1 &vY2 &vArrObj &vPts &vCurLayer &vNewLine &vModelSpace &vNewBlockObj &vXdType2 &vXdData2)
    (prompt "\n    Creating Viewport Link...")
    ;;(setq &vSS1 (ssget "_X" (list (cons 0 "INSERT")(cons 2 &vBlockName)(cons -3 "ViewPortAssocation"))))
    (setq &vVlaent (vlax-ename->vla-object &gVpEnt))
    (setq &vEntHandle (vlax-get-property &vVlaent "Handle"))
    (vlax-invoke-method &vVlaent "GetXData" "" '&vXdType '&vXdData)
	(setq &vCnX (vlax-variant-value (vlax-safearray-get-element &vXdData 8)))
	(setq &vCnY (vlax-variant-value (vlax-safearray-get-element &vXdData 9)))
    (setq &vVpScale (/ 1 (vlax-get-property &vVlaent "CustomScale")))
	(setq &vWidth (* (vlax-get-property &vVlaent "width") &vVpScale))
	(setq &vHeight (* (vlax-get-property &vVlaent "height") &vVpScale))
    (setq &vBlockName (strcat "ViewPortAssociation_MSObject_" &vEntHandle))
    (setq &vSS1 (ssget "_X" (list (cons 0 "INSERT")(cons 2 &vBlockName))))
    (if &vSS1
        ;;  one or more blocks were found with that name
        (progn
            ;;  delete all objects in the drawin with that name
            (while (not (= (sslength &vSS1) 0))
                (setq &vEnt (ssname &vSS1 0))
                (setq &vVlaent (vlax-ename->vla-object &vEnt))
                (vlax-invoke-method &vVlaent "Delete")
                (ssdel &vEnt &vSS1)
            )
        )
    )
    ;;  delete the block definition if it exists.
    (setq &vBlockColl (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
    (setq &vCnt 0)
    (while (<= &vCnt (- (vlax-get-property &vBlockColl "Count") 1))
        (setq &vBlockObj (vlax-invoke-method &vBlockColl "item" &vCnt))
        (if (= (vlax-get-property &vBlockObj "Name") &vBlockName)
            (progn
                (vlax-invoke-method &vBlockObj "Delete")
            )
        )
        (setq &vCnt (+ &vCnt 1))
    )
    ;;  after removing any blocks with that name then create the new block
    ;;  and add the polyline.
	(setq &vNewBlock (vlax-invoke-method &vBlockColl "Add" (vlax-3D-point &vCnX &vCnY) &vBlockName))

    (setq &vX1 (- &vCnX (* &vWidth 0.5)))
	(setq &vY1 (- &vCnY (* &vHeight 0.5)))
	(setq &vX2 (+ &vCnX (* &vWidth 0.5)))
	(setq &vY2 (+ &vCnY (* &vHeight 0.5)))

	(setq &vArrObj (vlax-make-safearray vlax-vbdouble '(0 . 7)))
	(vlax-safearray-put-element &vArrObj 0 &vX1)
	(vlax-safearray-put-element &vArrObj 1 &vY1)
	(vlax-safearray-put-element &vArrObj 2 &vX2)
	(vlax-safearray-put-element &vArrObj 3 &vY1)
	(vlax-safearray-put-element &vArrObj 4 &vX2)
	(vlax-safearray-put-element &vArrObj 5 &vY2)
	(vlax-safearray-put-element &vArrObj 6 &vX1)
	(vlax-safearray-put-element &vArrObj 7 &vY2)
	(setq &vPts (vlax-make-variant &vArrObj))

    (setq &vCurLayer (getvar "clayer"))

    ;;	temporary layer section.
    ;;(hlay:setLayer "1_Vport_MS")
	(if(= (tblsearch "layer" "1_Vport_MS") nil)
  	    (command "-layer" "m" "1_Vport_MS" "c" 1 "" "p" "n" "" "lt" "continuous" "" "")
  		(command "-layer" "s" "1_Vport_MS" "c" 1 "" "p" "n" "" "lt" "continuous" "" "")
  	)
    (setq &vNewLine (vlax-invoke-method &vNewBlock "AddLightWeightPolyLine" &vPts))
    (vlax-put-property &vNewLine "closed" :vlax-true)

    (setq &vModelSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
	(setq &vNewBlockObj (vlax-invoke-method &vModelSpace "InsertBlock" (vlax-3D-point &vCnX &vCnY) &vBlockName 1.0 1.0 1.0 0.0))
    (setq &vXdType nil)
    (setq &vXdData nil)
    (setq &vXdType (vlax-make-safearray vlax-vbInteger '(0 . 6)))
    	(vlax-safearray-put-element &vXdType 0 1001)
    	(vlax-safearray-put-element &vXdType 1 1000)
    	(vlax-safearray-put-element &vXdType 2 1002)
    	(vlax-safearray-put-element &vXdType 3 1040)
    	(vlax-safearray-put-element &vXdType 4 1040)
    	(vlax-safearray-put-element &vXdType 5 1040)
    	(vlax-safearray-put-element &vXdType 6 1002)
    (setq &vXdType2 (vlax-make-variant &vXdType))

	(setq &vXdData (vlax-make-safearray vlax-vbVariant '(0 . 6)))
	    (vlax-safearray-put-element &vXdData 0 "ViewPortAssociation")
	    (vlax-safearray-put-element &vXdData 1 &vEntHandle)
	    (vlax-safearray-put-element &vXdData 2 "{")
	    (vlax-safearray-put-element &vXdData 3 &vVpScale)
	    (vlax-safearray-put-element &vXdData 4 &vHeight)
	    (vlax-safearray-put-element &vXdData 5 &vWidth)
	    (vlax-safearray-put-element &vXdData 6 "}")

	(setq &vXdData2 (vlax-make-variant &vXdData))

	(vlax-invoke-method &vNewBlockObj "SetXData" &vXdType2 &vXdData2)

    (setvar "clayer" &vCurLayer)

     ;;	release vl objects
	(if &vVlaent (vlax-release-object &vVlaent))
	(if &vBlockColl (vlax-release-object &vBlockColl))
	(if &vBlockObj (vlax-release-object &vBlockObj))
	(if &vNewBlock (vlax-release-object &vNewBlock))
	(if &vNewLine (vlax-release-object &vNewLine))
	(if &vModelSpace (vlax-release-object &vModelSpace))
	(if &vNewBlockObj (vlax-release-object &vNewBlockObj))
    (princ)
)

(defun c:hvpo_getXData ( / &vEnt &vVlaent &vXdType &vXdData &vCnt &vObj1 &vObj2)
	(setq &vEnt (car (entsel)))
	(setq &vVlaent (vlax-ename->vla-object &vEnt))
	(vlax-invoke-method &vVlaent "GetXData" "" '&vXdType '&vXdData)

	(if &vXdType
		(progn
			(setq &vXdType (vlax-safearray->list &vXdType))
			(setq &vXdData (vlax-safearray->list &vXdData))

			(setq &vCnt 0)
			(while (<= &vCnt (- (length &vXdData) 1))
				(setq &vObj1 (nth &vCnt &vXdType))
				(setq &vObj2 (nth &vCnt &vXdData))
				(cond
					((= (vlax-variant-type &vObj2) 5)
						(prompt (strcat "\n " (itoa &vCnt) " - Type: " (vl-princ-to-string &vObj1) " -- Data: " (vl-princ-to-string (vlax-variant-value &vObj2)))))
					((= (vlax-variant-type &vObj2) 8)
						(prompt (strcat "\n " (itoa &vCnt) " - Type: " (vl-princ-to-string &vObj1) " -- Data: " (vl-princ-to-string (vlax-variant-value &vObj2)))))
					(prompt (strcat "\n " (itoa &vCnt) " - Type: " (vl-princ-to-string &vObj1) " -- Data: " ))
				)
				(setq &vCnt (+ &vCnt 1))
			)
		)
		(prompt "\n No XData found on selected Item\n")
	)
	 ;;	release vl objects
	(if &vVlaent (vlax-release-object &vVlaent))

	(princ)
)

(defun c:hvpo_ss (/ &vEnt &vVlaent &vXdType &vXdData &vVpScale &vDisc)
	(setq &vEnt (entsel "Select a Viewport outline:"))
	(if &vEnt
		(progn
			(setq &vEnt (car &vEnt))
			(setq &vVlaent (vlax-ename->vla-object &vEnt))
			(vlax-invoke-method &vVlaent "GetXData" "ViewPortAssociation" '&vXdType '&vXdData)

			(if &vXdData
				(progn
					(setq &vVpScale (vlax-variant-value (vlax-safearray-get-element &vXdData 3)))
					(setq &vDisc (hasl:getDiscipline))
   					(if &vDisc
   						(hgen:setWorkingScale (atoi (rtos &vVpScale 2 0)) &vDisc "ASL_TEXT")
   						(alert "Error getting discipline. Cannot set scale.")
   					)
				)
				(prompt "\n  Object is not a viewport outline")
			)
		)
		(prompt "\n  No entity selected.")
	)
	;;	release vl objects
	(if &vVlaent (vlax-release-object &vVlaent))

	(princ)
)

(prompt "\n\n..Viewport_helper module loaded. To see a list of commands type hvpo_help.")
(princ)

 

Just type hvpo_sync in the command line after uploading the lsp file.

hope this helps.

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...