Hey Team,
I am currently attempting to run a polyline between two blocks (first_block, second_block) that runs along another polyline, at the end of the action an insert function is called that populates an annotation block (cable_name_tag) using data taken from the start and end block.
This polyline will need to transect other blocks and as stated will primarily run in paralell with an underlying polyline (cable_ducting) and it will be the user who will need to select an appropriate part of the polyline to drop the annotation, as space is sometimes limited.
I have noted that if I comment out the second_block and provide a harcoded value the ssget function works without issue, so I am reasonably sure the issue is with either with the syntax or the handling of the first_block and second_block and data in that code.
Code example below:
Code:
(defun c:cable ()
(vl-load-com)
(setvar "clayer" "cable layer")
(setvar "celtype" "bylayer")
(setvar "osmode" 515 )
(command "_.pline"
(getpoint)
)
(while
(>
(getvar ' cmdactive) 0
)
(command pause)
(princ "\npress enter to finish:")
)
(setq elst
(entsel "\nselect cable segment: ")
)
(setq ename
(car elst)
)
(setq pt
(cadr elst)
)
(setq annopt pt)
(setq pt
(vlax-curve-getclosestpointto ename pt)
)
(setq param
(vlax-curve-getparamatpoint ename pt)
)
(setq preparam
(fix param)
)
(setq postparam
(1+ preparam)
)
(list
(setq pt1
(vlax-curve-getpointatparam ename preparam)
)
(setq pt2
(vlax-curve-getpointatparam ename postparam)
)
)
(setq cable
(entlast)
)
(setq cable_start
(vlax-curve-getstartparam cable)
)
(setq cable_start_point
(vlax-curve-getstartpoint cable)
)
(setq cable_end_point
(vlax-curve-getendpoint cable)
)
(setq cable_end
(angtos
(angle '
(0 0 )
(vlax-curve-getfirstderiv cable 0.0)
)
)
)
(setq first_block
(ssget "_c" cable_start_point cable_end_point
(list
(cons 0 "insert")
(cons 2 "first_block")
)
)
)
(setq second_block
(ssget "_c" cable_start_point cable_end_point
(list
(cons 0 "insert")
(cons 2 "second_block")
)
)
)
(setq end_cable
(ssname second_block 0)
)
(setq start_cable
(ssname first_block 0)
)
(setq $end_cable
(vla-get-textstring
(cadr
(vlax-safearray->list
(variant-value
(vla-getattributes
(vlax-ename->vla-object end_cable)
)
)
)
)
)
)
(setq $start_cable
(vla-get-textstring
(cadr
(vlax-safearray->list
(variant-value
(vla-getattributes
(vlax-ename->vla-object start_cable)
)
)
)
)
)
)
(setq cable_name
(vlax-curve-getendparam cable)
)
(command
; insert cable param
"-insert"
"cable_name_tag"
annopt
"1"
"1"
cable_angle
cable_name
$start_cable
$end_cable
"144"
cable_length
)
); end of duct function
I am relatively new to vLisp and such, but am very keen to get my teeth into it - and excited to see the results of joining the AUGI forums.
Thanks for your time