Creating a Autolisp Application Source File from a given code

Creating a Autolisp Application Source File from a given code

astofer
Participant Participant
1,070 Views
3 Replies
Message 1 of 4

Creating a Autolisp Application Source File from a given code

astofer
Participant
Participant

I have a 3d model exported from Revit for a very complicated building im soon to be doing layout and quality checks for. I've been able to successfully break these down into poly and 3d poly lines in the past. However when I exploded this particular model it turns into polyface mesh and further explodes into 3d faces. I found a lisp routine code that is supposed to be able to automatically break this all down frm polyface mesh into poly and 3d poly lines. However I have next to no experience with Lisp routines. I found another Lisp that does something similar to the one Im asking about thats already in an Autolisp Application file and was able to easily load that all on with the guidance from these forums. While it works to a degree its still not quite doing what I need it to do. Id like to try this source code I found but have no idea how to make this into an easily loadable app file. Any help or guidance would be appreciated. Also if you have any good Lisp Applications for a construction surveyor I'd love to see if they could stream line my Civil 3d time. Here is the code I found and would like to convert. Im using 2024 Civil 3d if that makes any difference.

 

(defun c:XplPgMesh

(/ oApp oDoc oMSp oObj vXplObj aXplObj oObjLst oObj2 vCoords o3dPline)
(VL-LOAD-COM)
(setq oApp (vlax-get-acad-object)
oDoc (vla-get-activedocument oApp)
oMSp (vla-get-modelspace oDoc)
) ;setq
(vlax-for oObj oMsp
(if (= (vla-get-objectname oObj) "AcDbPolygonMesh")
(if (setq vXplObj (vla-explode oObj))
(progn
(setq aXplObj (vlax-variant-value vXplObj))
(if (not (minusp (vlax-safearray-get-u-bound aXplObj 1)))
(progn
(setq oObjLst (vlax-safearray->list aXplObj))
(foreach oObj2 oObjLst
(if (= (vla-get-objectname oObj2) "AcDbFace")
(progn
(setq vCoords (vla-get-coordinates oObj2)
o3dPline (vla-Add3DPoly oMSp vCoords)
) ;setq
(vlax-put-property o3dPline 'Closed :vlax-true)
(vla-delete oObj2)
(vlax-release-object o3dPline)
) ;progn
) ;if
) ;foreach
(foreach itm oObjLst (vlax-release-object itm))
) ;progn
) ;if
(vla-delete oObj)
) ;progn
) ;if
) ;if
) ;vlax-for
(princ)
)

0 Likes
Accepted solutions (2)
1,071 Views
3 Replies
Replies (3)
Message 2 of 4

MikeEvansUK
Advisor
Advisor
Accepted solution

I think you just need to rename the .txt file to a Lsp then use appload to run.

 

The function XplPgMesh should then be visible from command line and run.

 

I'm not really a Lsp guy, but do create new files copied from others who know Auto Lsp programming using the above.

If that doesn't work, you need to seek advice in the customisation forum as those who know live there.

 

Mike

Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

Message 3 of 4

MMcCall402
Mentor
Mentor
Accepted solution

Save, or rename the current .TXT file you have with a file extension of .LSP  Then drag and drop that file into your civil 3d drawing.   Now enter XplPgMesh at the command line to run the lisp.

 

 

Mark Mccall 
CAD Mangler


EESignature


VHB - Engineering, Inc.

Message 4 of 4

astofer
Participant
Participant

Thank you both! I did get it to be able to convert and load in however it seems to not be working should I repost this code in the customization forum per MikeEvans suggestion to see if someone can back check it?

0 Likes