markv Posted March 2, 2010 Posted March 2, 2010 Below is a VBA routine that gets a selection set of blocks and modifies the linetypes of Arcs and splines within the block. I am attempting to convert to VLISP. I have the basic selection set working, however I am at a loss on how to access the nested arcs and splines. Sub ChBlockEntProp() Dim filtertype(4) As Integer Dim filterdata(4) As Variant Dim objSSet As AcadSelectionSet filtertype(0) = 0 filterdata(0) = "INSERT" filtertype(1) = -4 filterdata(1) = "<or" filtertype(2) = 8 filterdata(2) = "a-hist" filtertype(3) = 8 filterdata(3) = "a-hist-2000" filtertype(4) = -4 filterdata(4) = "or>" Set objSSet = ThisDrawing.SelectionSets.Add("BlkSet") objSSet.Select acSelectionSetAll, , , filtertype, filterdata Dim objBlock As AcadBlock Dim objBlkRef As AcadBlockReference Dim objCadEnt As AcadEntity For Each objBlkRef In objSSet For Each objBlock In ThisDrawing.Blocks If StrComp(objBlkRef.Name, objBlock.Name) = 0 Then For Each objCadEnt In objBlock With objCadEnt If .ObjectName = "AcDbArc" Or .ObjectName = "AcDbSpline" Then .Linetype = "continuous" End If End With Next End If Next Next Set objCadEnt = Nothing Set objBlkRef = Nothing Set objBlock = Nothing objSSet.Delete ThisDrawing.Regen acActiveViewport ThisDrawing.SendCommand "_vbaunload" & vbCr & "fixhist.dvb" & vbCr End Sub Below is the LISP code so far (defun c:fH (/ objsset objblock objblkref objcadent) (vl-load-com) ; load the visual lisp extensions (Setq objsset (ssget "x" '((0 . "insert") (-4 . "<or") (8 . "A-HIST") (8 . "A-HIST-2000") (-4 . "or>"))));;;get selection set Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 Try this: (defun c:fH (/ GetName ss Nme done) (vl-load-com) (setq GetName (lambda (obj) (if (vlax-property-available-p obj 'EffectiveName) (vla-get-EffectiveName obj) (vla-get-Name obj))) *doc (cond (*doc) ((vla-get-ActiveDocument (vlax-get-acad-object))))) (if (ssget "_X" '((0 . "INSERT") (8 . "A-HIST,A-HIST-2000"))) (progn (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *doc)) (if (not (vl-position (setq Nme (GetName obj)) done)) (progn (vlax-for sub_obj (vla-item (vla-get-Blocks *doc) Nme) (if (vl-position (vla-get-ObjectName sub_obj) '("AcDbArc" "AcDbSpline")) (vla-put-Linetype sub_obj "CONTINUOUS"))) (setq done (cons Nme done))))) (vla-Regen *doc AcActiveViewport) (vla-delete ss))) (princ)) Quote
markv Posted March 2, 2010 Author Posted March 2, 2010 Thanks much that is nice a clean. Now me being a newbie at a lot of the visual lisp stuff. Can you tell me what lines are replacing what lines in the VBA routine? (the how and why) This will help me for future programs Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 Its not really a line for line - I looked at what the VBA routine does and wrote a corresponding VLISP code But basically it gets the SelSet, iterates through it, and, for each block, if it hasn't already seen the block before, it iterates through the objects in the block definition and checks for Splines/Arcs. Quote
Recommended Posts
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.