+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Newbie
    MEP 2015
    Join Date
    Jan 2015

    Default Lisp to select cid#

    Registered forum members do not see this ad.

    Hi, I am working in Fabrication and am trying to make a lisp that will select all items of a certain cid# (4 and 61) and then run a ctext on them. The lisp is also supposed to run a script at the same time, but that part works fine.

    This is my code so far...

    (defun c:etag()
    (setq ss (ssget))
    (setvar "pickfirst" 1)
    (sssetfirst nil ss)
    (executescript "Elbow Tagger.cod")
    	if item.cid = 4, 61 then
    	(addctext "AMCI-Full-Elbow-Tag")
    	end if
    end select)
    Currently, this lisp will apply the ctext to very part selected. I am only familiar with VB so I was a little lost when trying to tell the lisp to select cid#

  2. #2
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Dell Precision T3600
    Hex-Core Intel Xeon 3.2Ghz
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Dual 24" Dell Ultrasharp Widescreen Monitors
    BlackBox's Discipline Details
    Senior Civil Designer
    Public/Private Land Development, Transportation, and Utilities.
    Civil 3D 2016
    Join Date
    Nov 2009


    Welcome to CADTutor.

    More information is needed; the code you posted includes some sub-functions which aren't defined, and perhaps a sample drawing so others might be able to test their offerings?

    If you post what you're after in VB, C#, etc. I may be able to help port that down to LISP... Presuming, of course, that the appropriate Properties, and Methods are exposed to LISP (not sure what AMEP Command[s] you're calling in your Script either).

    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  3. #3
    Forum Newbie
    MEP 2015
    Join Date
    Jan 2015


    Registered forum members do not see this ad.

    I'm not sure what you mean by a sample drawing but I can definitely elaborate on the sub functions.

    "Elbow Tagger.COD" is a script I made in visual basic language to fill in the tag-1, tag-2 and tag-3 fields of sheet metal elbows. I will include its code in the box bellow...

    select item.cid
    	case 4
    	dim QUOTE = ascii(34)
    	dim extl = 0
    	dim exts = 0
    	dim exti = item.dim["Top Extension"].numvalue
    	dim exto = item.dim["Bottom Extension"].numvalue
    	dim tag1 = item.customdata[7].value
    	dim rad = item.dim["Inner Radius"].numvalue
    	dim tag2 = item.customdata[8].value
    	dim tag3 = item.customdata[9].value
    	if exti < exto then
    	exts = exti
    	extl = exto
    	end if
    	if exti > exto then
    	exts = exto
    	extl = exti
    	end if
    	exts = Round((exts), 2)
    	extl = Round((extl), 2)
    	rad = Round((rad), 2)
    	item.customdata[7].value = rad + exts + ""+QUOTE+"" + "R"
    	if extl > 2 then
    	item.customdata[8].value = extl + ""+QUOTE+"" + "EXT"
    	end if
    	if exts > 2 then
    	item.customdata[9].value = exts + ""+QUOTE+"" + "EXT"
    	end if
    end select
    select item.cid
    	case 61
    	dim QUOTE = ascii(34)
    	item.customdata[7].value = item.dim["Inner Radius"].numvalue + ""+QUOTE+"" +"R"
    end select
    That part works just fine, but the next bit has been giving me trouble.

    "AMCI-Full-Elbow-Tag" is a ctext I made which creates a tag with 4 fields. 1 field is for the angle of the elbow and the other 3 fields are for the tag-1, tag-2, and tag-3 fields which the "Elbow Tagger.COD" script fills in.

    I only want the ctext to apply to items which have a cid identification number of 4 and/or 61 but at present, it effects everything I drag select.

    I would of loved to do this whole thing in a VB script but people have been telling me that scripts cannot load ctext reports so I am trying to load both my script and my ctext from a lisp.

    I suppose, if the ctext portion of the lisp were to be in VB, it would probably look something like this....but I am not an experienced programmer so I could be way off.

    select item.cid
           case 4, 61
           addctext "AMCI-Full-Elbow-Tag"
    end select
    Thanks a lot for offering to help and being so friendly. Some people can be snarky when I ask a beginner question.

Similar Threads

  1. LISP for Select the same entities again...
    By toberino in forum AutoLISP, Visual LISP & DCL
    Replies: 40
    Last Post: 20th Aug 2012, 09:26 am
  2. select xrefs lisp
    By daisenson in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 9th Oct 2010, 02:35 pm
  3. Select Text LISP
    By vmuntean in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 27th Apr 2010, 08:04 am
  4. LISP to Select and Sort
    By geocad in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 11th Nov 2009, 11:57 pm

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts