Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Lets just say I am lost!!!!!!!!! VBA to Visual Lisp

Lets just say I am lost!!!!!!!!! VBA to Visual Lisp

Lets just say I am lost!!!!!!!!! VBA to Visual Lisp

Below is some code I am attempting to translate to visual lisp. We have upgraded to 2010 and would like to get away from the VBA editor and I can see it will eventually just go away. What it does is takes some blocks on two specific layers and changes the arcs and/or splines and changes the lintype to continous. The blocks are all related to project numbers and have 100's of different names. I think I may be on the right track with the selection set but dont know what I need to do next.I have commented out the VBA code.


(defun c:fixhist ()         ;;; Sub ChBlockEntProp()
(vl-load-com);;;Dim objSSet As AcadSelectionSet
(SETQ SS1 (SSGET "x" '((0 . "insert")(-4 . "<or")(8 . "a-hist")(8 . "a-hist-2000")(-4 . "or>"))));;;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
;;;Set objCadEnt = Nothing
;;;Set objBlkRef = Nothing
;;;Set objBlock = Nothing
;;;ThisDrawing.Regen acActiveViewport
;;;ThisDrawing.SendCommand "_vbaunload" & vbCr & "fixhist.dvb" & vbCr
;;;End Sub

RE: Lets just say I am lost!!!!!!!!! VBA to Visual Lisp

I have since been updating the code. It now looks nothing like this. I will post new code if needed. Thanks for any help

RE: Lets just say I am lost!!!!!!!!! VBA to Visual Lisp

I have some new code. The selection set works fine.I changed the layer just to see if my selection set would work.( i dont need to do that) How do I select the arc and/or spline objects within the block definitions and change the lintype? I am a bit lost.


(defun c:fH (/ ssets acadDocument newsset ctr item)
  (vl-load-com)                ; load the visual lisp extensions
  (setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
                    ;retrieve a reference to the documents object
  (setq ssets (vla-get-selectionsets acadDocument))

                    ;retrieve a reference to the selection sets object
  (setq newsset (vla-add ssets "SS1"))    ;add a new selection set
  (setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 4)))
                    ;create a 5 element array for the DXF Code
  (setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 4)))
;;;;create a 5 element array for the values
  (vlax-safearray-fill filter_code '(0 -4 8 8 -4))
;;;;DXF Code for Objects and Layer
    '("insert" "<OR" "A-Hist" "A-HIST-2000" "OR>")
;;;;the filter values
    newsset acSelectionSetAll nil nil filter_code filter_value)
;;;;select ALL Blocks on Layers A-hist or a-hist-2000
  (setq ctr 0)                ;set the counter to zero
  (repeat (vla-get-count newsset)    ;count the number of objects and loop
    (setq item (vla-item newsset ctr))    ;retrieve each object
    (setq check (vlax-property-available-p item "LAYER" T))
                    ;check if the entity has a layer property and can it be updated
    (if    check                ;if it can
      (vlax-put-property item 'LAYER "A-WALL-SLAB") ;change it's layer
    )                    ; end if
    (setq ctr (1+ ctr))            ;increment the counter
  )                    ;repeat
  (vla-delete (vla-item ssets "SS1"))    ;delete the selection set
)                    ;defun

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close